<?php

    function get_tinyurl($url) {
        $query = "http://tinyurl.com/api-create.php?url=".urlencode($url);
        $tiny = trim(file_get_contents($query));
        if ($tiny && strpos($tiny, "http://tinyurl.com/") === 0) {
            return $tiny;
        }

        return null;
    }

?>
